#!/bin/sh
# 此版本shell中：if[ $# = 0 ]可行，if[ $# == 0 ]不可行,if[ $#=0 ]不可行
#CONFIG_FILE=a.c 中间不可以有空格，右值不需要引号
if [ $# = 0 ];then

    echo "no input!!"
    exit 1

fi

CONFIG_FILE=/etc/apt/sources.list


if [ $1 = 20 ];then
    echo   "change to source 20.04"
    echo   "#source 20.04"                                                                                    > ${CONFIG_FILE}
    echo   "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse"                  >> ${CONFIG_FILE}
    echo   "deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse"              >> ${CONFIG_FILE}
    echo   "deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse"         >> ${CONFIG_FILE}
    echo   "deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse"     >> ${CONFIG_FILE}
    echo   "deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse"          >> ${CONFIG_FILE}
    echo   "deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse"      >> ${CONFIG_FILE}
    echo   "deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse"         >> ${CONFIG_FILE}
    echo   "deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse"     >> ${CONFIG_FILE}
    echo   "deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse"        >> ${CONFIG_FILE}
    echo   "deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse"    >> ${CONFIG_FILE}

elif [ $1 = 18 ];then
echo "change to source 18.04"
cat > ${CONFIG_FILE} << EOF
#source 18.04
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
EOF

else

    echo "input error!!"
    exit 1
fi

sudo apt update
